package com.hwpt.controller.admin;


import com.hwpt.dto.admin.BatchDeleteFeedBackDTO;
import com.hwpt.dto.admin.FeedbackListDTO;
import com.hwpt.result.PageResult;
import com.hwpt.result.Result;
import com.hwpt.service.FeedBackService;
import com.hwpt.vo.admin.FeedBackDetailVO;
import com.hwpt.vo.admin.ListFeedbackVO;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/feedback") // 正确：通过@RequestMapping定义API路径
@Slf4j
@RequiredArgsConstructor
@Tag(name = "用户反馈接口")
@Controller("adminFeedBackController")
public class FeedBackController {

    private final FeedBackService feedBackService;

    @GetMapping("/list")
    @ApiOperation("管理员-用户反馈列表")
    public Result<PageResult<ListFeedbackVO>> feedbackList(@RequestBody FeedbackListDTO feedbackListDTO) {
        PageResult<ListFeedbackVO> listFeedbackVOPageResult = feedBackService.feedbackList(feedbackListDTO);
        return Result.success(listFeedbackVOPageResult);
    }

    @GetMapping("/feedback/{feedbackId}")
    @ApiOperation("管理员-用户反馈详情")
    public Result<FeedBackDetailVO> feedbackDetail(@PathVariable Long feedbackId) {
        FeedBackDetailVO feedBackDetailVO = feedBackService.feedbackDetail(feedbackId);
        return Result.success(feedBackDetailVO);
    }

    @PutMapping("/{feedbackId}/status")
    @ApiOperation("管理员-更新反馈状态")
    public Result<Void> updateFeedbackStatus(@PathVariable Long feedbackId) {
        feedBackService.updateFeedbackStatus(feedbackId);
        return Result.success();
    }

    @DeleteMapping("/{feedbackId}/delete")
    @ApiOperation("管理员删除反馈")
    public Result<Void> deleteFeedback(@PathVariable Long feedbackId) {
        feedBackService.deleteFeedback(feedbackId);
        return Result.success();
    }

    @DeleteMapping("/batch-delete")
    @ApiOperation("管理员批量删除反馈")
    public Result<Void> batchDeleteFeedback(@RequestBody BatchDeleteFeedBackDTO batchDeleteFeedBackDTO) {
        log.info("管理员批量删除反馈，反馈ID列表：{}", batchDeleteFeedBackDTO.getFeedbackIds());
        feedBackService.batchDeleteFeedback(batchDeleteFeedBackDTO);
        return Result.success();
    }
}
